/*******************************************************************************
 ** Name: ansi.cpp                                                            **
 ** Description: WorldObject-derived container objects                        **
 **                                                                           **
 ** Open Source Initiative (OSI) Approved License                             **
 **                                                                           **
 ** The contents of this file are subject to the terms of the                 **
 ** Common Development and Distribution License, Version 1.0 only             **
 ** (the "License").  You may not use this file except in compliance          **
 ** with the License.                                                         **
 **                                                                           **
 ** You can find a copy of the license in the LICENSE file within             **
 ** this distribution or at $WIKI/display/GOVT/License-software.              **
 ** Software distributed under the License is distributed on an "AS IS"       **
 ** basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.           **
 ** See the License for the specific language governing permissions           **
 ** and limitations under the License.                                        **
 **                                                                           **
 ** When distributing Covered Code, include this CDDL header in each          **
 ** file and include the License file at $GAME_DIR/LICENSE.                   **
 ** If applicable, add the following below this header, with the indicated    **
 ** fields enclosed by brackets "[]" replaced with your own identifying       **
 ** information: Portions Copyright [yyyy] [name of copyright owner]          **
 **                                                                           **
 ** Copyright (c) 2009-2011  Barry Gian James <gian@gamingods.net>            **
 ** All rights reserved.                                                      **
 ******************************************************************************/
// Created on March 17, 2010, 8:21 AM
// Modified $Date: 2012-08-14 20:47:30 -0600 (Tue, 14 Aug 2012) $ by $Author: unknown $
#define ansi_cpp_ID   "$Id: ansi.cpp 69068 2012-08-15 02:47:30Z unknown $"

#include "ansi.hpp"

#define CODE_COLOR_MAX 17

CodeToColor	ColorCodes[] =
{
		{ COLOR_CODE_BLACK, ANSI_BLACK },
		{ COLOR_CODE_RED, ANSI_RED },
		{ COLOR_CODE_DRED, ANSI_DRED },
		{ COLOR_CODE_GREEN, ANSI_GREEN },
		{ COLOR_CODE_DGREEN, ANSI_DGREEN },
		{ COLOR_CODE_YELLOW, ANSI_YELLOW },
		{ COLOR_CODE_ORANGE, ANSI_ORANGE },
		{ COLOR_CODE_BLUE, ANSI_BLUE },
		{ COLOR_CODE_DBLUE, ANSI_DBLUE },
		{ COLOR_CODE_MAGENTA, ANSI_DMAGENTA },
		{ COLOR_CODE_CYAN, ANSI_CYAN },
		{ COLOR_CODE_PINK, ANSI_PINK },
		{ COLOR_CODE_GREY, ANSI_GREY },
		{ COLOR_CODE_DGREY, ANSI_DGREY },
		{ COLOR_CODE_LBLUE, ANSI_LBLUE },
		{ COLOR_CODE_WHITE, ANSI_WHITE },
		{ COLOR_CODE_NORMAL, ANSI_NORMAL }
};

ColorToEvent ColorableEvents[] =
{
	{ Colorable::plain, ANSI_GREY },
	{ Colorable::action, ANSI_GREEN }

};

std::string ReplaceCode(std::string & c)
{
	for (int i = 0; i < CODE_COLOR_MAX; i++)
	{
		if (ColorCodes[i].code == c)
			return ColorCodes[i].color;
	}
	return ANSI_NORMAL;
}

// returns the actual length of the string without the color codes
size_t ansi_strlen(const char * s)
{
	return 0;
}

// ch = "ffr" or "fbb" etc for "foreground faint red"
//      and "foreground bold blue". Parsed as "#ffr" and "#fbb"
//void TextToColor(int s, const char * ch)
//{
//	// Test foreground
//	// TODO
//	if (ch[0] == 'n') {
//		FONT_NORMAL(s);
//		return;
//	}
//	// Bold or faint
//	if (ch[1] == 'f')
//		FONT_FAINT(s);
//	else
//		FONT_BOLD(s);
//
//	switch(ch[2])
//	{
//	case 'r':
//		FONT_BRED(s);
//		break;
//	case 'g':
//		FONT_GREEN(s);
//		break;
//	case 'y':
//		FONT_YELLOW(s);
//		break;
//	case 'b':
//		FONT_BLUE(s);
//		break;
//	case 'm':
//		FONT_MAGENTA(s);
//		break;
//	case 'c':
//		FONT_CYAN(s);
//		break;
//	case 'w':
//		FONT_WHITE(s);
//		break;
//	case 'p':
//		FONT_PINK(s);
//		break;
//	case 'l':
//		FONT_LBLUE(s);
//		break;
//	case 'd':
//		FONT_DBLUE(s);
//		break;
//	case 'R':
//		FONT_DRED(s);
//
//	case 'n':
//	default:
//		FONT_NORMAL(s);
//		break;
//	}
//}
